
{% extends TEMPLATE_BASE %}
{% block title %}Confirm Vote{% endblock %}

{% block content %}
<script language="javascript">
$(document).ready(function() {
  $('#waiting_div').hide();
});

function show_waiting() {
  $('#all_forms').hide();
  $('#waiting_div').show();
}

// FIXME: set this to false once it's clear how to set it back to true
// so that it's not easy to forget to cast a ballot
var ready_to_unload = true;

window.onbeforeunload = function(evt) {
  if (ready_to_unload)
    return;

  if (typeof evt == 'undefined') {
    evt = window.event;
  }

  var message = "You have not yet cast your ballot! Make sure to complete the voting process if you want your vote to count.";

  if (evt) {
    evt.returnValue = message;
  }

  return message;
};

</script>
<h1>请别离开页面!<br />您还未投出选票.</h1>

<div id="waiting_div">
    正在验证和投出您的选票<br />
    <img src="/static/helios/loading.gif" />
</div>

<div style="word-wrap: break-word; width: 90vw;">
您的选票追踪器是:<br>
<b>{{vote_fingerprint}}</b>
<br><br>
</div>

<div id="all_forms">

{% if voter %}

{% include "_castconfirm_docast.html" %}

{% else %}

{% if show_password %}
{% with cast_ballot="1" %}
{% include "_castconfirm_password.html" %}
{% endwith %}

{% else %}

{% if user %}
<h1>抱歉!<h1>
<b>抱歉, 您 <em>
  {% if election.openreg %}
    <u>没有资格</u></em> 进行投票.
  {% else %}
    您未登记参加本次选举</em>，并且登记已关闭.
  {% endif %}
  </b><br /></p>
<p>
    [<a href="{% url "election@view" election.uuid %}">返回选举主页面</a>]
</p>
{% else %}
<p>
{% if election.openreg %}

  {% if election.eligibility %}
  {% else %}
   此选举对<em>任何人</em>开放, 请登录您的账户参加投票.
  {% endif %}

{% else %}
  此选举只针对 <em>注册用户</em>开放, 请登录与注册时相同的账户进行投票.
{% endif %}
</p>

{{login_box|safe}}

<br />
别担心，当您登录后，我们会记住你的选票信息.
{% endif %}

{% endif %}
</p>
{# this closes the IF ELSE of this being password_only #}
{% endif %}

</div>

{% endblock %}
